#ifndef _SASLGSSAPIMECHANISM_H_
#define _SASLGSSAPIMECHANISM_H_

/**
 * Implementation of the SASL GSSAPI mechanisn
 * 
 *
 * @author Jay Kline
 */
class SASLGSSAPIMechanism : public SASLMechanism {
public:
	SASLGSSAPIMechanism(SASLAuthentication * saslAuthentication) {};
	
    /**
     * Builds and sends the <tt>auth</tt> stanza to the server.
     * This overrides from the abstract class because the initial token
     * needed for GSSAPI is binary, and not safe to put in a string, thus
     * getAuthenticationText() cannot be used.
     *
     * @param username the username of the user being authenticated.
     * @param host     the hostname where the user account resides.
     * @param password the password of the user (ignored for GSSAPI)
     * @throws IOException If a network error occures while authenticating.
     */
    void authenticate(std::string & username, std::string & host, std::string & password);
	
    /**
     * The server is challenging the SASL mechanism for the stanza he just sent. Send a
     * response to the server's challenge. This overrieds from the abstract class because the
     * tokens needed for GSSAPI are binary, and not safe to put in a string, thus 
     * getChallengeResponse() cannot be used.
     *
     * @param challenge a base64 encoded string representing the challenge.
     */
    void challengeReceived(std::string & challenge);
	
protected:
	std::string getName() {
        return "GSSAPI";
    }

	std::string getAuthenticationText(std::string & username, std::string & host, std::string & password);
	
	std::string getChallengeResponse(/*byte[] bytes*/) {
        // Unused, see challengeReceived
        return NULL;
    }

private:

	static std::string protocol;
    static std::string[] mechanisms;
    SaslClient * sc;

};

#endif // -- _SASLGSSAPIMECHANISM_H_
